package com.neuedu.his.service;

import com.neuedu.his.entity.CheckApply;
import com.neuedu.his.mapper.CheckApplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
@Transactional
public class CheckApplyServiceImpl implements CheckApplyService{

    @Autowired
    CheckApplyMapper CheMapper;

    @Override
    public CheckApply selectById(CheckApply che) {
        return CheMapper.selectById(che);
    }

    @Override
    public List<CheckApply> selectAll(CheckApply che) {
        return CheMapper.selectAll(che);
    }

    @Override
    public List<CheckApply> selectByName(CheckApply che) {
        return CheMapper.selectByName(che);
    }

    @Override
    public int update(CheckApply che) {
        return CheMapper.update(che);
    }

    @Override
    public int delete(CheckApply che) {
        if(CheMapper.selectById(che).getState() != 2){
            return CheMapper.delete(che);
        }else{
            return 0;
        }
    }

    @Override
    public List<CheckApply> selectByRegistId(CheckApply che) {
        return CheMapper.selectByRegistId(che);
    }

    @Override
    public List<CheckApply> selectByState(CheckApply che){
        return CheMapper.selectByState(che);
    }

    @Override
    public int updateToStorage(CheckApply che) {
        che.setState(1);
        return CheMapper.update(che);
    }

    @Override
    public int updateToOpen(CheckApply che) {
        che.setState(2);
        return CheMapper.update(che);
    }

//    @Override
//    public int updateToDefinite(CheckApply che){
//        che.setState(3);
//        return CheMapper.update(che);
//    }

}
